package com.sumainfor.pc.market.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.CommunityGetService;
import com.sumainfor.pc.market.service.RdTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 查询房源信息
 * <p>
 *
 * @author: zhoucong
 * @create: 2019-04-10 15:09
 **/
@RestController
@RequestMapping("/key/CommunityGet")
public class CommunityGetController {


    @Autowired
    private CommunityGetService communityGetService;

    /**
     * 根据房源编号 分页 模糊 条件查询房源信息
     *
     * @return
     */
    @PostMapping("/getCommunityLists")
    public JsonResult getCommunityLists(@RequestBody Map<String, Object> params
            , Pager pager) {
        System.out.println("传递的参数params:"+params);
        pager.setPageno(Integer.parseInt(params.get("pageno").toString()));
        pager.setPagesize(Integer.parseInt(params.get("pagesize").toString()));
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=communityGetService.getCommunityListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=communityGetService.getCommunityList(params);
        return pageUtils.getJsonResult(getCommunityList, params, cout);
    }



}
